package com.miloyu.modelnet.network.service

import com.miloyu.modelnet.network.BaseResponse
import com.miloyu.modelnet.request.AddTrainPlanDTO
import com.miloyu.modelnet.request.SportEndBeanItem
import com.miloyu.modelnet.response.*
import io.reactivex.Observable
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.*

/**
 * @Author: YY
 * @Time: 2021/8/11
 * @Describe TODO
 */
interface IApiService {

    /**
     * 上传图片
     */
    @POST("/upload/uploadFile")
    @Multipart
    fun uploadFile(
        @Part file: MultipartBody.Part?
    ): Observable<BaseResponse<FileInfoVO>>

    /**
     * 获取图片域名
     *
     * @describe app所有列表图片都需要加上此域名，
     * 接口只返回域名后缀的图片路径例如 /profile/123.png，
     * 需要自行加上路径，富文本除外
     */
    @POST("/basics/config/imagePrefix")
    fun getImagePrefix(): Observable<BaseResponse<ImagePrefixVO>>

    /**
     * 用户协议
     */
    @POST("/basics/info/userAgreement")
    fun userAgreement(): Observable<BaseResponse<UserAgreementVO>>

    /**
     * 登录
     */
    @POST("/login")
    @FormUrlEncoded
    fun login(
        @Field("username") username: String,
        @Field("password") password: String,
        @Field("code") code: String
    ): Observable<BaseResponse<TokenVO>>

    /**
     * 注册
     */
    @POST("/register")
    @FormUrlEncoded
    fun register(
        @Field("userPhone") userPhone: String,
        @Field("password") password: String,
        @Field("validcode") validcode: String
    ): Observable<BaseResponse<Void>>

    /**
     * 忘记密码
     */
    @POST("/autn/forgetPassword")
    @FormUrlEncoded
    fun forgetPassword(
        @Field("userPhone") userPhone: String,
        @Field("password") password: String,
        @Field("validcode") validcode: String
    ): Observable<BaseResponse<TokenVO>>

    /**
     * 修改登录密码
     */
    @POST("/customer/user/updatePassword")
    @FormUrlEncoded
    fun modifyPassword(
        @Field("password") password: String,
        @Field("validcode") validcode: String
    ): Observable<BaseResponse<TokenVO>>

    /**
     * 发送注册短信接口
     */
    @POST("/basics/sms/register")
    @FormUrlEncoded
    fun sendRegisterSms(
        @Field("phone") phone: String,
    ): Observable<BaseResponse<Void>>

    /**
     * 发送忘记密码短信接口
     */
    @POST("/basics/sms/retrieve")
    @FormUrlEncoded
    fun sendModifySms(
        @Field("phone") phone: String,
    ): Observable<BaseResponse<Void>>


    /**
     * 退出登录
     */
    @POST("/logout")
    fun loginOut(): Observable<BaseResponse<Void>>

    /**
     * 检查版本更新
     */
    @POST("/basics/config/version")
    fun checkUpVersion(): Observable<BaseResponse<VersionVOWrap>>

    /**
     * 个人信息
     */
    @POST("/customer/user/info")
    @Headers("cache: userInfo")
    fun userInfo(): Observable<BaseResponse<UserInfoVO>>

    /**
     * 修改昵称和头像
     */
    @POST("/customer/user/edit")
    @FormUrlEncoded
    fun modifyUserInfo(
        @Field("userPhoto") userPhoto: String,
        @Field("userNickname") userNickname: String,
        @Field("userSex") userSex: String,
        @Field("userBirthday") userBirthday: String,
        @Field("userHeight") userHeight: String,
        @Field("userWeight") userWeight: String,
    ): Observable<BaseResponse<Void>>

    /**
     * 消息/公告
     */
    @POST("/notice/system/list")
    fun getNotice(): Observable<BaseResponse<SysNoticesWrap>>


    /**
     * 学过课程
     */
    @POST("/curriculum/log/list")
    fun learnedCourse(): Observable<BaseResponse<LearnedCourseWrap>>


    /**
     * 我的收藏
     */
    @POST("curriculum/collection/list")
    fun getCollectList(): Observable<BaseResponse<LearnedCourseWrap>>


    /**
     * 删除收藏课程
     */
    @POST("/curriculum/collection//remove/{id}")
    fun deleteCollectCourse(
        @Path("id") id: String,
    ): Observable<BaseResponse<Void>>


    /**
     * 帮助中心
     */
    @POST("/basics/info")
    fun getHelpInfo(): Observable<BaseResponse<HelpInfoWrap>>

    /**
     * 会员套餐
     */
    @POST("/basics/level/list")
    fun memberSetMeal(): Observable<BaseResponse<MemberSetMealWrap>>

    /**
     * 支付列表
     * @param model web-网页 app-客户端
     */
    @POST("/basics/paymode/list")
    @FormUrlEncoded
    fun payModeInfo(
        @Field("model") model: String
    ): Observable<BaseResponse<PayModeWrap>>

    /**
     * 添加训练计划
     */
    @POST("/customer/plan/save")
    fun addTrainPlan(@Body dto: AddTrainPlanDTO): Observable<BaseResponse<Void>>

    /**
     * 根据月计划查询
     */
    @POST("/customer/plan/month")
    @FormUrlEncoded
    fun monthPlanState(
        @Field("month") month: String
    )
            : Observable<BaseResponse<PlanStatusWrap>>

    /**
     * 根据天查询计划
     */
    @POST("/customer/plan/day")
    @FormUrlEncoded
    fun dayPlanList(
        @Field("day") day: String,
        @Field("curriculumType") curriculumType: String? = null
    ): Observable<BaseResponse<TrainPlanWrap>>

    /**
     * 删除计划
     */
    @POST("/customer/plan//delete/{id}")
    @FormUrlEncoded
    fun deletePlan(
        @Path("id") id: String,
        @Field("day") day: String
    ): Observable<BaseResponse<Void>>

    /**
     *首页视频
     */
    @POST("basics/banner/info/1")
    fun getHomeVideo(): Observable<BaseResponse<AppBanner>>

    /**
     *课程列表类型
     */
    @POST("basics/config/queryDictType")
    fun getCourseTypeList(
        @Query("dictType") dictType: String = "t_curriculum"
    )
            : Observable<BaseResponse<CourseTypeListBean>>

    /**
     * 查询计划类型
     */
    @POST("/customer/plan/curriculum")
    fun queryPlanType(): Observable<BaseResponse<PlanTypeListBean>>

    /**
     *课程列表
     */
    @POST("/curriculum/list")
    @FormUrlEncoded
    fun getCurriculumList(
        @Field("curriculumType") curriculumType: String
    ): Observable<BaseResponse<CourseListBean>>

    /**
     * 锻炼一级列表
     */
    @POST("/basics/category/list/{type}")
    fun getCategoryList(@Path("type") type: Int): Observable<BaseResponse<TrainListBean>>

    /**
     *锻炼二级列表
     */
    @POST("/basics/category/parent/{parentId}")
    fun getCategoryParentList(@Path("parentId") parentId: Int): Observable<BaseResponse<TrainListBean>>

    @POST("/customer/user/perfectInfo")
    @FormUrlEncoded
    fun perfectInfo(
        @Field("birthday") birthday: String,
        @Field("sex") sex: String,
        @Field("height") height: String,
        @Field("weight") weight: String,
        @Field("targetWeight") targetWeight: String,
        @Field("target") target: String?,
    ): Observable<BaseResponse<Void?>>

    /**
     *动作列表
     */
    @POST("/basics/category/ids")
    fun getActionList(@Query("ids") ids: String): Observable<BaseResponse<TrainListSetting>>

    /**
     * 查询课程动作
     */
    @POST(" /curriculum/detail/{curriculum}")
    fun getCourseVideo(
        @Path("curriculum") curriculum: String
    ): Observable<BaseResponse<CourseVideoVO>>

    /**
     * 添加收藏
     */
    @POST("/curriculum/collection/collection/{id}")
    fun addCollection(
        @Path("id") id: String
    ): Observable<BaseResponse<Void>>

    /**
     * 取消收藏
     */
    @POST("/curriculum/collection//remove/{id}")
    fun cancelCollection(
        @Path("id") id: String
    ): Observable<BaseResponse<Void>>

    /**
     * 首页
     */
    @POST("/home/{id}")
    fun reqHome(
        @Path("id") id: Int
    ): Observable<BaseResponse<HomeInfoVO>>

    /**
     * 会员协议
     */
    @POST("/basics/info/vipNotes")
    fun vipNotes(): Observable<BaseResponse<VipNotesVO>>

    /**
     * 开通套餐
     */
    @POST("/payment/level/{id}")
    @FormUrlEncoded
    fun openMember(
        @Path("id") id: String,
        @Field("payid") payid: Int,
    ): Observable<BaseResponse<OpenMemberVO>>

    /**
     * 邀请好友
     */
    @POST("/customer/user/share")
    fun inviteFriend(): Observable<BaseResponse<InviteShareVO>>

    /**
     * 绑定手机号
     */
    @POST("/bindingPhone")
    @FormUrlEncoded
    fun bindPhone(
        @Field("openid") openid: String,
        @Field("phone") phone: String,
        @Field("code") code: String,
    ): Observable<BaseResponse<TokenVO>>

    /**
     * 获取微信登录二维码信息
     */
    @POST("/token/sdkTicket")
    fun getSdkTicket(): Observable<BaseResponse<TicketVO>>

    /**
     * 上报运行
     */
    @POST("/customer/plan/log/report/{type}")
    @FormUrlEncoded
    fun reportCourseTrain(
        @Path("type") type: String,
        @Field("id") id: Int,
        @Field("duration") duration: Int,
        @Field("calorie") calorie: String,
    ): Observable<BaseResponse<Void>>


    @POST("/app/cash")
    @FormUrlEncoded
    fun loadCash(@Field("data") day: String): Observable<BaseResponse<Void>>

    @POST("/customer/plan/log/report")
    fun sportEnd(
        @Body() datas: List<SportEndBeanItem>
    ): Observable<BaseResponse<SportEndResponse>>

    /**
     *首页视频 (训练结束)
     */
    @POST("/basics/banner/info/2")
    fun getSportEndVideo(): Observable<BaseResponse<AppBanner>>

    /**
     * 过去一周运动趋势
     */
    @POST("/customer/plan/sevenDays")
    fun getLastWeekSport(): Observable<BaseResponse<LastWeekSport>>

    /**
     * 获取智能设备类型
     */
    @POST("/basics/iot/list")
    fun getSmartDeviceType(): Observable<BaseResponse<SmartDeviceWrap>>

    /**
     *启动页视频
     */
    @POST("/basics/banner/info/3")
    fun getSplashUrl(): Observable<BaseResponse<AppBanner>>

    @POST("/basics/sms/validCode")
    @FormUrlEncoded
    fun checkVCode(
        @Field("phone") phone: String,
        @Field("validCode") validCode: String
    ): Observable<BaseResponse<Void>>

    @POST("/basics/iot/checkKey")
    @FormUrlEncoded
    //String key,String longitude,String latitude
    fun checkLocation(
        @Field("key") key: String,
        @Field("longitude") longitude: String,
        @Field("latitude") latitude: String
    ): Observable<BaseResponse<Void>>

    @POST("/basics/category/select-movement-category")
    @FormUrlEncoded
    fun getCategoryList(): Observable<BaseResponse<CategoryList>>

}